import requests
from bs4 import BeautifulSoup

def getHTMLText(url):
    try:
        r=requests.get(url)
        r.raise_for_status()
        print(r.status_code)
        r.encoding=r.apparent_encoding
        return r.text
    except:
        print("抓取失败!")
        
def fillList(ulist,html):
    soup = BeautifulSoup(html,"html.parser")
    print(soup.title.string)
    print(soup.)
    
def output(data=''):
    #file = open("ip138.html","w",encoding="utf-8")
    #file.write(data)
    #file.close()
    print(data)
    
def main():
    uinfo=[]
    url = "http://www.xbmu.edu.cn/frontIndex.action?siteId=1"
    html = getHTMLText(url)
    fillList(uinfo,html)
    #output(uinfo)
    
    print("\n抓取成功!")
    

main()
